package com.zzf.activitytest2

import android.content.Context
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import kotlinx.android.synthetic.main.second_layout.*

class SecondActivity : BaseActivity() {

    companion object{
        fun actionStart(context:Context,datal:String,data2:String){
            val intent = Intent(context,SecondActivity::class.java)
            intent.putExtra("param1",datal)
            intent.putExtra("param2",data2)
            context.startActivity(intent)
        }
    }


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.second_layout)

//        取出intent中的数据
//        val extraData = intent.getStringExtra("extra_data")
//        Log.d("SecondActivity","extra data is $extraData")

        button2.setOnClickListener {
//            val intent = Intent()
//            intent.putExtra("data_return","Hello FirstActivity")
//            setResult(RESULT_OK,intent)
//            finish()

            val intent = Intent(this,ThridActivity::class.java)
            startActivity(intent)
        }
    }

    //按下返回键，页面即将消失
    override fun onBackPressed() {
        val intent = Intent()
        intent.putExtra("data_return","Hello FirstActivity")
        setResult(RESULT_OK,intent)
        super.onBackPressed()
    }
}